package top.kpromise.user.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import top.kpromise.user.model.response.UserInfoModel;

@Repository
public interface UserInfoMapper {

    @Insert("insert into user_info (userId, nickName, createAt, updateAt, birthday, profilePhoto, link, city, province, " +
            "phone, email, signature, gender) values (#{userId}, #{nickName}, #{createAt}, #{updateAt}, #{birthday}, " +
            "#{profilePhoto}, #{link}, #{city}, #{province}, #{phone}, #{email}, #{signature}, #{gender})")
    int insert(UserInfoModel userInfoModel);

    @Select("select * from user_info where userId = #{userId} limit 1")
    UserInfoModel getByUserId(String userId);

    @Update("update user_info set nickName = #{nickName}, birthday = #{birthday}, profilePhoto = #{profilePhoto}, " +
            "link = #{link}, city = #{city}, province = #{province}, signature = #{signature}, updateAt = #{updateAt}, " +
            "gender = #{gender} where userId = #{userId} limit 1")
    int update(UserInfoModel userInfoModel);
}
